package 事务练习.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import 事务练习.dao.UserDao;
import 事务练习.entity.TbUser;

/**
 * @author caihe
 * @date 2021/6/2 10:49
 */
@Service
public class UserService {

    @Autowired
    private UserDao userDao;
    

    @Transactional(isolation = Isolation.SERIALIZABLE,propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public void a()  {
        userDao.addUser("xiya", "123");
        TbUser xiya = userDao.selectUser("xiya");
        throw new RuntimeException("error");
    }




}
